package com.wondersgroup.model;

import com.fr.base.FRContext;
import com.fr.general.data.DataModel;
import com.fr.general.data.TableDataException;

import java.util.Map;
import java.util.logging.Level;

/**
 * Created by Xtra on 3/22 0022.
 */

/**
 * 参数查询表数据
 */
public class ParQueryTableModel implements DataModel {

    private String[] itemDataName;
    private Map<String, String> itemDataValue;

    public ParQueryTableModel(String[] itemDataName, Map<String, String> itemDataValue) {
        this.itemDataName = itemDataName;
        this.itemDataValue = itemDataValue;
    }

    @Override
    public int getColumnCount() throws TableDataException {
        return itemDataName.length;
    }

    @Override
    public String getColumnName(int i) throws TableDataException {
        FRContext.getLogger().log(Level.INFO, "*****生成表格列名中！*****");
        return itemDataName[i];
    }

    @Override
    public boolean hasRow(int i) throws TableDataException {
        return false;
    }

    @Override
    public int getRowCount() throws TableDataException {
        return 1;
    }

    @Override
    public Object getValueAt(int i, int i1) throws TableDataException {
        FRContext.getLogger().log(Level.INFO, "*****正在给表格赋值*****");
        return itemDataValue.get(itemDataName[i1]);
    }

    @Override
    public void release() throws Exception {

    }
}
